package campaus.manager;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import android.util.Log;

public class HttpServer {
	public static void postData(String userid,String password){
		String destUrl = "http://192.168.1.105/DB.php";
		HttpEntityEnclosingRequestBase httpRequest = new HttpPost(destUrl);
		List<NameValuePair>params = new ArrayList<NameValuePair>();
		params.add(new BasicNameValuePair("userid",userid));
		params.add(new BasicNameValuePair("password",password));
		try{
			httpRequest.setEntity(new UrlEncodedFormEntity(params,HTTP.UTF_8));
			HttpResponse httpResponse = new DefaultHttpClient().execute(httpRequest);
			if(httpResponse.getStatusLine().getStatusCode()==200){
				StringBuilder builder = new StringBuilder();
				BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent()));
				for(String s=bufferedReader.readLine();s!=null;s=bufferedReader.readLine()){
					builder.append(s);
				}
				Log.i("cat",">>>>>>"+builder.toString());
			}
		}
		catch(Exception e){
			
		}
	}
}
